<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>Business</Title>
			<Shortcut>gbus</Shortcut>
			<Description>ZEQP Business自动生成</Description>
			<Author>ZEQP</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
				<SnippetType>SurroundsWith</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal>
					<ID>name</ID>
					<ToolTip>实体名称</ToolTip>
					<Default>CF_Entity</Default>
				</Literal>
			</Declarations>
			<Code Language="csharp">
        <![CDATA[using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Linq.Dynamic.Core;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using PMS.XCMG.Entity;
using PMS.XCMG.IBusiness;
using PMS.XCMG.Util;
using PMS.XCMG.Models;

namespace PMS.XCMG.Business
{
    public class $name$Business : BusRepository<$name$>, I$name$Business, IScopedDependency
    {
        private IServiceProvider SvcProvider { get; set; }
        public $name$Business(GDbContext context, IServiceProvider svcProvider)
            : base(context)
        {
            this.SvcProvider = svcProvider;
        }

        public async Task<PageResult<$name$>> GetPageResultAsync(PageInput<$name$QM> query)
        {
            var queryable = this.GetQueryable(true);
            var search = query.Search;
            if (!search.Keyword.IsNullOrEmpty())
                queryable = queryable.Where(w => w.Name.Contains(search.Keyword) || w.Code.Contains(search.Keyword));
            $end$
            
            var result = await this.GetPageResultAsync(queryable, query);
            if (!search.Id.IsNullOrEmpty())
            {
                if (!result.Data.Any(w => w.Id == search.Id))
                {
                    var idOne = await this.GetQueryable(true).SingleOrDefaultAsync(w => w.Id == search.Id);
                    result.Data.Add(idOne);
                    result.Total += 1;
                }
            }
            return result;
        }
    }
}
]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>
